//
//  YDAlertView.m
//  YDAlertShow
//
//  Created by James on 16/5/8.
//  Copyright © 2016年 bearbaby. All rights reserved.
//

#import "YDAlertView.h"
#import "ViewController.h"
@implementation YDAlertView
-(instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}
-(void)initView{

    self.titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, YDMain_width*0.8, [YDAlertView alertHeight]/4.2)];
    self.titleView.backgroundColor = [UIColor whiteColor];
    
    self.contentView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleView.frame), YDMain_width*0.8, [YDAlertView alertHeight]-[YDAlertView alertHeight]/2.1)];
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleView.frame), self.contentView.width, 1)];
    lineView.backgroundColor = [UIColor grayColor];
   // [self.contentView addSubview:lineView];
    self.buttonView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.contentView.frame), self.titleView.width, [YDAlertView alertHeight]-CGRectGetMaxY(self.contentView.frame))];
    //self.buttonView.backgroundColor = [UIColor brownColor];
    
    self.layer.cornerRadius = 10;
    self.layer.masksToBounds = YES;
    
    [self addSubview:self.titleView];
    [self addSubview:self.contentView];
    [self addSubview:self.buttonView];
    [self addSubview:lineView];
 
}
//- (void)drawRect:(CGRect)rect {
//    [super drawRect:rect];
//    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(YDMain_width/60, YDMain_width)];
//    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
//    maskLayer.frame = self.bounds;
//    maskLayer.path = maskPath.CGPath;
//    self.layer.mask = maskLayer;
//}
+(CGFloat)alertHeight{

    return YDMain_width*0.6;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
